package com.wanshu.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wanshu.sys.model.SysLogQueryDto;
import com.wanshu.common.util.PageUtils;
import com.wanshu.sys.entity.SysLog;
import com.wanshu.sys.mapper.SysLogMapper;
import com.wanshu.sys.service.ISysLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 系统日志 服务实现类
 * </p>
 *
 * @author yh
 * @since 2023-06-09
 */
@Service
public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> implements ISysLogService {

    @Override
    public PageUtils<SysLog> queryPage(SysLogQueryDto qDto) {
        LambdaQueryWrapper<SysLog> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(StringUtils.isNotEmpty(qDto.getUserName()), SysLog::getUsername, qDto.getUserName())
                .like(StringUtils.isNotEmpty(qDto.getOperation()), SysLog::getOperation, qDto.getOperation());
        Page<SysLog> page = this.page(qDto.page(), wrapper);
        return new PageUtils(page);
    }
}
